<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" ></meta>
    <title>详细内容</title>
    <script src="${assets}/js/views/vue.min.js"></script>
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap.min.css" type="text/css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/base/base.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/common.css" type="text/css">
    <%@ include file="/WEB-INF/jsp/component/commonBottom.jsp" %>
    <link rel="stylesheet" href="${assets}/css/views/department/addDepartment.css">
    <link rel="stylesheet" href="${assets}/css/select-bootstrap.css">
    <script src="${assets}/js/select-bootstrap.js"></script>
    <%--<script src="../assets/js/views/cleanInput.js"></script>--%>
    <style>
        *{
            padding:0;
            list-style: none;
            text-decoration: none;
            font-weight:100;
            font-family:"微软雅黑";
        }
        span,label{
            font:17px/33px '微软雅黑';
            display:inline-block;
        }
        h3{
            font:16px/30px '微软雅黑';
            color:black;
        }
        body{
            width:98%;
            margin:0 auto;
            height:100%;
        }
        /*内容信息*/
        .img{
            width:170px;
            display:inline-block;
        }
        .form{
            display:inline-block;
            height:500px;
            overflow-y:scroll;
            overflow-x:hidden;
            width:500px;
        }
        .form label{
            width:85px;
        }
        .form div{
            margin:10px 0;
        }
        .form input{
            width:250px;
        }
        .btn-group{
            width:250px !important;
            height:32px !important;
        }
        .dropdown-toggle{
            margin-top:0px !important
        }
        .btn-group button{
            padding:0 !important
        }
        input,select{
            border:1px solid #d0d0d0;
            font:15px/30px '微软雅黑';
            color:black;
            text-indent:1rem;
        }
        span{
            text-indent:1rem;
            font:15px/30px '微软雅黑';
        }
        img{
            max-width:100%;
            height:auto;
        }
        .img{
            width:150px;
            float:left;
            margin-top:10px;
        }
        #height{
            position:absolute;
        }
        #height_unit{
            position:relative;
            left:210px;
            border-left:1px solid #d0d0d0;
            width:40px;
            display:inline-block;
            text-align:center;
        }
        #weight{
            position:absolute;
        }
        #weight_unit{
            position:relative;
            left:210px;
            border-left:1px solid #d0d0d0;
            width:40px;
            display:inline-block;
            text-align:center;
        }
        #waist{
            position:absolute;
        }
        #waist_unit{
            position:relative;
            left:210px;
            border-left:1px solid #d0d0d0;
            width:40px;
            display:inline-block;
            text-align:center;
        }
        .modal-body{
            height: auto !important
        }
        #keep{
            background:#35acfd !important;
        }
        .change{
            width:100%;
        }
        .btn-active {
            width: 100px;
            line-height: 15px;
            background: #35acfd;
            color: white;
            margin-top:15px;
        }
        .modal-footer{
            width:255px;
            margin:0 auto;
        }
        .content{
            width:90%;
            margin:0 auto;
            overflow:hidden;
        }
        input{
            border: solid 1px #d0d0d0;
            width:250px !important;
            height:32px !important;
            vertical-align:middle;
            display:inline-block !important;
        }
        .defualt{
            border:1px solid red !important;
        }
        input::-webkit-input-placeholder{
            color:red;
        }
        input::-moz-placeholder{   /* Mozilla Firefox 19+ */
            color:red;
        }
        input:-moz-placeholder{    /* Mozilla Firefox 4 to 18 */
            color:red;
        }
        input:-ms-input-placeholder{  /* Internet Explorer 10-11 */
            color:red;
        }
        .positionDiv{
            position:relative;
            height:35px;
        }
    </style>
</head>
<body>
<div style="width:100%;overflow:hidden;">
    <div class="header">
        <h1>病人基本信息</h1>
    </div>
    <div class="content" id="main">
        <div class="img">
            <img src="${assets}/images/img1.png" alt="头像">
        </div>
        <div class="form">
            <form>
                <div>
                    <label for="name"><h3>姓名</h3></label>
                    <input type="text" class="form-control" id="name" value="${entity.realname}">
                </div>
                <div>
                    <label for="idcard"><h3>身份证</h3></label>
                    <input type="text" class="form-control" id="idcard" readonly="readonly" value="${entity.idcard}">
                </div>
                <div class="positionDiv">
                    <label for="height"><h3>身高</h3></label>
                    <input type="text" class="form-control" id="height" value="${entity.height}" onkeyup="value=value.replace(/[^\d.]/g,'')">
                    <span id="height_unit">cm</span>
                </div>
                <div class="positionDiv">
                    <label for="weight"><h3>体重</h3></label>
                    <input type="text" class="form-control" id="weight" value="${entity.weight}" onkeyup="value=value.replace(/[^\d.]/g,'')">
                    <span id="weight_unit">kg</span>
                </div>
                <div class="positionDiv">
                    <label for="waist"><h3>腰围</h3></label>
                    <input type="text" class="form-control" id="waist" value="${entity.waist}" onkeyup="value=value.replace(/[^\d.]/g,'')">
                    <span id="waist_unit">cm</span>
                </div>
                <div>
                    <label for="mobile"><h3>联系电话</h3></label>
                    <input type="text" class="form-control" id="mobile" value="${entity.phone}" onkeyup="value=value.replace(/[^\d.]/g,'')">
                </div>
                <div>
                    <label for="phone"><h3>固定电话</h3></label>
                    <input type="text" class="form-control" id="phone" value="${entity.contactphone}" onkeyup="value=value.replace(/[^\d.]/g,'')" >
                </div>
                <div>
                    <label for="address"><h3>地址</h3></label>
                    <input type="text" class="form-control" id="address" value="${entity.homeaddress}">
                </div>
                <div style="margin:0px;">
                    <label for="diseaseDiagnosis"><h3>现患疾病诊断信息</h3></label>
                    <input type="text" class="form-control" id="diseaseDiagnosis" value="${entity.diseaseDiagnosis}" style="vertical-align: middle;margin-bottom:30px;">
                </div>
                <div style="margin:0px;">
                    <label for="diseasesType"><h3>疾病分类</h3></label>
                    <select name="diseasesType" class="selectpicker" id="diseasesType" multiple>
                        <option value="1">高血压人群</option>
                        <option value="2">糖尿病人群</option>
                        <option value="3">高血脂人群</option>
                        <option value="4">骨松人群</option>
                        <option value="5">失智人群</option>
                    </select>
                </div>
                <div style="margin:0px;">
                    <label for="levelManagement"><h3>级别管理</h3></label>
                    <select name="levelManagement" class="selectpicker" id="levelManagement" v-model="${entity.levelManagement}">
                        <option value="" selected="selected">请选择</option>
                        <option value="1">高危</option>
                        <option value="2">骨质疏松</option>
                        <option value="3">重度骨质疏松</option>
                    </select>
                </div>
                <div>
                    <label for="remark"><h3>备注</h3></label>
                    <input type="text" class="form-control" id="remark" value="${entity.remark}">
                </div>
            </form>
        </div>
        <div class="form-group submitBtn" style="text-align: center ">
            <button type="button" class="btn-active btn" data-dismiss="modal" id="closeModalButt" onclick="closeFrame()">
                关闭
            </button>
            <button type="submit" class="btn-active btn" id="keep"  onclick="keep()" style="margin-left:20px;">保存</button>
        </div>
    </div>
</div>
<script>
  var diseasesType = ''
  var urlLib = ''
  var refreshto = ''
  $(document).ready(function(){
    var typeList = [
      {
        id:'1',
        name:'高血压人群',
      },
      {
        id:'2',
        name:'糖尿病人群',
      },
      {
        id:'3',
        name:'高血脂人群',
      },
      {
        id:'4',
        name:'骨松人群'
      },
      {
        id:'5',
        name:'失智人群'
      }
    ]
    var url = location.search.split('?')
    var options = $('#diseasesType option')
      var optionss = $('#levelManagement option')
    var href = ('${entity.diseasesType}')
      var levelManagement = ('${entity.levelManagement}')
      if( levelManagement != '' && levelManagement != null ){
              if( levelManagement == 1  ){
                  optionss[1].selected = true
              }else if( levelManagement == 2 ){
                  optionss[2].selected = true
              }else if( levelManagement == 3 ){
                  optionss[3].selected = true
              }
      }
    if( href != '' && href != null ){
      var arr1 = href.split(",")
      if( arr1.length == 1 ){
        if( arr1[0] === '1' ){
          options[0].selected = true
        }else if( arr1[0] === '2' ){
          options[1].selected = true
        }else if( arr1[0] === '3' ){
          options[2].selected = true
        }else if( arr1[0] === '4' ){
          options[3].selected = true
        }else{
          options[4].selected = true
        }
      }else{
        console.log(arr1)
        typeList.forEach((item,index)=>{
          for( var a = 0; a < arr1.length; a++ ){
            if( item.id == arr1[a] ){
              options[index].selected = true
            }
          }
        })
      }
    } else{
      $(function() {
        $("#diseasesType").selectpicker({
          noneSelectedText: '请选择人群' //默认显示内容  
        });
      });
    }
    $.ajax({
      url:"${URL_SCREENING_GETBREADLINE}",
      dataType:'json',
      type:'post',
      success:function(data){
        urlLib = JSON.parse(data.data)
        refreshto = urlLib[urlLib.length-1].href
      }
    })
  })
  //关闭并刷新
  function closeFrame() {
    window.parent.simpleCloseModal();
  }
  function keep(){
    // 获取当前所哟u input 中的数据
    // 获取身份证
    var idcard = $("#idcard").val();
    // 获取病人姓名
    var realname = $("#name").val();
    // 获取身高参数
    var height = $("#height").val();
    if( height == '' ){
      height = 0
    }
    // 获取体重参数
    var weight = $("#weight").val()
    if( weight == '' ){
      weight = 0
    }
    // 获取联系电话
    var phone = $("#mobile").val();
    // 获取固定电话
    var contactphone = $("#phone").val();
    // 获取地址
    var address = $("#address").val();
    // 获取腰围
    var waist = $('#waist').val()
    var diseaseDiagnosis = $('#diseaseDiagnosis').val()
    var levelManagement = $('#levelManagement').val()
    // 疾病人群
    diseasesType = $('.filter-option').text()
    var arr = []
    $("#diseasesType option:selected").each(function () {
      arr.push($(this).val())
    })
    var remark = $('#remark').val()
          diseasesType = arr.toString()


      console.log(levelManagement)
    if( $('#name').val() === '' ){
      if( $('#name').hasClass('defualt') ){

      }else{
        $('#name').addClass('defualt')
        $('#name').focus()
        $('#name').attr('placeholder','请输入姓名')
      }
    }else{
      $.ajax({
        url : "${URL_PATIENT_UPDATEPATIENT}",
        dataType:"json",
        type:"post",
        data:{
          id:'${entity.id}',
          realname:realname,
          idcard:idcard,
          phone:phone,
          height:height,
          weight:weight,
          waist:waist,
          contactphone:contactphone,
          homeaddress:address,
          diseaseDiagnosis:diseaseDiagnosis,
            levelManagement:levelManagement,
          diseasesType:diseasesType,
          remark:remark
        },
        success:function( data ){
          console.log(data)
          if( data.success ){
            // 刷新当前页面
            parent.showSrc('${ctx}/boneLoose/qianhu/detail?idCard=' + idcard + '&diseasesType=5');
            // parent.showSrc(refreshto)
            window.parent.simpleCloseModal();
          }else if( !data.success ){
            alert(data.msg)
          }
        }
      })
    }
  }
  $('.selectpicker').bind('change',function(){
    if( $('.selectpicker option:selected').length == '0' ){
      $("#diseasesType").selectpicker({
        noneSelectedText: '请选择人群' //默认显示内容  
      });
    }
  })
</script>
</body>
</html>
